package com.zhoukx.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @ClassName OutPutImpl
 * @Description:对外输出类
 * @Author zhoukx
 * @Date 2020/8/17
 **/
public class OutPutImpl {

    // 学院集合
     List<Collage> collageList;

    public OutPutImpl(List<Collage> collageList) {
        this.collageList = collageList;
    }


    // 便利所有的学院   在输出各个学院的系
    public void printCollage(){
        Iterator<Collage> iterator = collageList.iterator();
        while (iterator.hasNext()) {

            Collage next = iterator.next();
            System.out.println("======="+next.getName()+"=========");
            printDepartment(next.createIterator()); // 对应的迭代器打印
        }
    }

    // 输出 学院输出系
    public  void printDepartment(Iterator iterator){
        while (iterator.hasNext()){
            Department next = (Department) iterator.next();
            System.out.println(next.getName());
        }
    }
}
